<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\Product\models\ProductRoomPrice;
use app\modules\Order\models\OrderRoom;
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style type="text/css">
        body{font-family: "Microsoft YaHei" !important;font-size: 9px;line-height: 150%;
        text-align: center;background: #EEE;}
        /** {margin: 0;padding: 0;}*/
        #printBtn{background: #FF9;border-bottom: 1px solid #999;padding: 3px 0;margin-bottom: 10px;text-align: center;}
        #wrapper{
                width: 300mm;
                margin: 0 auto;
                text-align: left;
                background: white;
                padding: 20mm;
                border-top: 1px solid #999;
                border-left: 1px solid #999;
                border-right: 4px solid #333;
                border-bottom: 4px solid #333;
        }
       
    </style>
</head>
<body>


<!-- <div id="printBtn">
    <a href="#" onclick="javascript:XDoc();">[另存为doc]</a>
   <a href="#" onclick="javascript:show();">[隐藏同业价格]</a> 
</div> -->




<div id="wrapper">

    <h1 style="color:#337ab7;font-size:18px;font-weight: bold;line-height:30px;height:60px;text-align: center;font-family: 'Microsoft YaHei'; "><?=$model->name?></h1>
    <p style="margin-bottom: 3mm;font-size: 10px;font-family: 'Microsoft YaHei';"><?=$model->cruise->desc;?></p>

    <?php if(!empty($model->sale)){?>
    <div style="margin-top: 10px;">
        <p style="color: red;font-size: 16px;font-weight: bold;margin-bottom:3mm;font-family: 'Microsoft YaHei';">优惠信息:</p>
        <div style="margin:0;padding: 0;font-size: 10pt;font-family: 'Microsoft YaHei';color: red"><?=$model->sale;?></div>
    </div>    
     <?php }?>

    <div style="margin-top: 10px;">
         <h2 style="color:#337ab7;font-size: 14pt;font-weight: bold;margin-bottom:3mm;font-family: 'Microsoft YaHei';"><?=sprintf("%s游轮船舱销售价格:", $model->code);?></h2>
         
         <?php if($model->stock == 1){ ?>
             <table width="300mm" style="table-layout: fixed;border-collapse: collapse;">
                <thead>
                    <tr>
                        <th width="40%" style="width:400px;background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">舱型</p></th>
                        <th width="20%" style="width:200px;background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">楼层</p></th>
                        <th width="20%" style="width:200px;background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">外卖价/人</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="20%" style="width:200px;background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">同行价/人</p></th>
                         <?php }?>
                    </tr>

                </thead>
                <tbody>
                <?php  foreach($model->productRoom as $val){ ?>
                     <?php if($val->show ==1 && !empty($val->price)){ ?>   
                        <?php
                        $name = sprintf("%s%s %s人房",$val->room->name, $val->room->code, $val->people); 
                        ?>
                        <tr>
                            <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><p style="text-align: center;"><?=$name?></p></td>
                            <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><p style="text-align: center;"><?=yii::$app->ceils->getCeils($val->room->ceil)?></p></td>
                            <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color:red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                                <p style="text-align: center;">
                                <?php if(isset($val->sell_out) && $val->sell_out == 1){ ?>
                                    售罄
                                <?php }else{ ?>
                                    <?=$val->price?>
                                <?php }?>
                                </p>
                                </td>
                            <?php if($type == 1){ ?>
                            <td class="in-show" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color:red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><p style="text-align: center;">
                                <?php if(isset($val->sell_out) && $val->sell_out == 1){ ?>
                                    售罄
                                <?php }else{ ?>
                                    <?=$val->inside_price?>
                                <?php }?>
                                </p>
                            </td>
                            <?php }?>
                        </tr>
                       <?php };?> 
                   
                    <?php };?>
         

                </tbody>
            </table>   
        <?php }elseif($model->stock == 2){?>
        
             <table class="table_price2"  width="300mm" style="table-layout: fixed;border-collapse: collapse;">
                <thead>
                    <tr>
                        <th width="15%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">名称</p></th>
                        <th width="15%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">第1/2人价格</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="15%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">第1/2人同业价格</p></th>
                        <?php }?>
                        <th width="15%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">第3/4人价格</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="15%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">第3/4人同业价格</p></th>
                        <?php }?>
                        <th width="10%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">单间差</p></th>
                        <th width="15%" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">备注</p></th>
                    </tr>

                </thead>
                <tbody>
                <?php if(!empty($model->rooms)){ 
                         $data_rooms = json_decode($model->rooms,true);
                ?>
                <?php   if(is_array($data_rooms)){ ?>
                <?php foreach($data_rooms as $rid=>$val){?>
                        <?php 
                            $use_num = 0;
                            $use_num = OrderRoom::find()->where(['room_id'=>$rid,'product_id'=>$model->id,'status'=>1])->count();
                        ?>
                        <tr>
                        <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><?=(!empty($val['name']))?$val['name']:"—";?></td>
                        <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                 <?=(!empty($val['price']))?$val['price']:"—";?>
                            <?php }?>    
                            </td>
                        <?php if($type == 1){ ?>
                        <td class="in-show" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color:red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                <?=(!empty($val['inside_price']))?$val['inside_price']:"—";?>
                            <?php }?>      
                            </td>
                        <?php }?>
                        <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                <?=(!empty($val['price2']))?$val['price2']:"—";?>
                            <?php }?>    
                            </td>
                        <?php if($type == 1){ ?>
                        <td class="in-show" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                 <?=(!empty($val['inside_price2']))?$val['inside_price2']:"—";?>
                            <?php }?>    
                            </td>
                        <?php }?>
                        <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                  <?=(!empty($val['difference']))?$val['difference']:"—";?>
                            <?php }?>
                            </td>
                        <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><?=(!empty($val['remark']))?$val['remark']:"—";?></td>
                        </tr>
                <?php };?>
                <?php };?>
                <?php };?>    
                </tbody>
            </table>   

        <?php }?>    
        
    </div>

    <div style="color: #000000;font-size:18pt;font-weight: bold;margin-top: 20px;text-align: center;">
        旅游费用包含和不含项目、以及取消政策
    </div>

    <table style="width:300mm;margin-top: 10px;border: 2px solid #A664A6;border-collapse:collapse;" border="2" >
        <thead border="2">
            <tr style="background: #A664A6;height: 40px;text-align: center;font-weight: bold;color: #FFFFFF;font-family: 'Microsoft YaHei';">
                <td style="width: 45%;background: #A664A6;border: 2px solid #A664A6;font-weight: bold;color: #FFFFFF;font-family: 'Microsoft YaHei';"><p style="text-align: center;">旅游费用包含项目</p></td>
                <td style="width: 55%;background: #A664A6;border: 2px solid #A664A6;font-weight: bold;color: #FFFFFF;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">旅游费用不包含项目</p></td>
            </tr>
        </thead>
        <tbody>
            <tr style="text-align:justify;">
                <td style="padding-right: 10px;">
                     <?php if(!empty($model->cost)){?>
            
                        <div style="font-size: 10pt;font-family: 'Microsoft YaHei';"><?=$model->cost;?></div>
                   
                    <?php }?>  
                </td>
                <td style="border-left:2px solid #A664A6;padding-right: 10px;">
                     <?php if(!empty($model->nocost)){?>
            
                        <div style="font-size: 10pt;font-family: 'Microsoft YaHei';"><?=$model->nocost;?></div>
                    
                    <?php }?>    
                </td>
            </tr> 
            <tr style="text-align:justify;">
                <td colspan=2 style="padding-left:15px;padding-right: 15px;border-top:2px solid #A664A6;">
                    <?php if(!empty($model->cancel)){?>
                    <div style="margin-top: 10px;">
                        <h1 style="color: #000000;font-size: 12px;font-family: 'Microsoft YaHei';">取消政策:</h1>
                        <div style="margin:0;padding: 0;font-size: 10px;font-family: 'Microsoft YaHei';"><?=$model->cancel;?></div>
                    </div>    
                     <?php }?>
                </td>
            </tr>
        </tbody>
        
    </table>

     <div class="detail" style="width: 100%">
        <h2 style="color:#337ab7;font-size: 14px;font-family: 'Microsoft YaHei';font-weight: bold;margin-bottom:3mm;"><?=sprintf("行程 (%s - %s)", $model->go_time, $model->return_time);?></h2>
        <?php 
              $weekarray = array("日","一","二","三","四","五","六");  
              $trip = json_decode($model->trip, true);
              ksort($trip);   
              $dates = Yii::$app->dates->prDates($model->go_time, $model->return_time);
        ?>
        <?php if($model->type == 1 || $model->type == 3){ ?> 
        <table width="300mm" style="width:300mm;table-layout: fixed;border-collapse: collapse;" border="1" bordercolor="#337ab7">
            <thead style="width:300mm;">
                <tr style="width:300mm;">
                    <th  style="width:10%;background: #337ab7;font-weight: bold;border: 1px solid #337ab7;padding: 2mm;font-size: 9pt;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;color: #FFFFFF;height: 30px;line-height: 30px;">天数</p></th>
                    <th  style="width:25%;background: #337ab7;font-weight: bold;border: 1px solid #337ab7;padding: 2mm;font-size: 9pt;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;color: #FFFFFF;height: 30px;line-height: 30px;">日期</p></th>
                    <th style="width:30%;background: #337ab7;font-weight: bold;padding: 2mm;font-size: 9pt;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;color: #FFFFFF;height: 30px;line-height: 30px;">停靠城市</p></th>
                    <th  style="width:10%;background: #337ab7;font-weight: bold;border: 1px solid #337ab7;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;color: #FFFFFF;height: 30px;line-height: 30px;">预计到达时间</p></th>
                    <th  style="width:10%;background: #337ab7;font-weight: bold;border: 1px solid #337ab7;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;color: #FFFFFF;height: 30px;line-height: 30px;">预计出发时间</p></th>
                    <th  style="width:15%;background: #337ab7;font-weight: bold;border: 1px solid #337ab7;padding: 2mm;color: #FFFFFF;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;color: #FFFFFF;height: 30px;line-height: 30px;">船上餐食</p></th>
                </tr>

            </thead>

            <tbody>
         
            <?php foreach($trip as $key=>$val){?>
            <tr>           
                <td style="width:10%;padding: 1mm;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;"><?=sprintf("第%s天", $key+1);?></p></td>
                <td style="width:25%;padding: 1mm;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;"><?=date("Y年m月d日",strtotime($dates[$key]))?></p></td>
                <td style="width:30%;padding: 1mm;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="font-weight: bold;margin:0;text-align: center;">
                        <?=$val['title']?></p></td>
                <td style="width:10%;padding: 1mm;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;"><?=!empty($val['time1'])?$val['time1']:'——'?></p></td>
                <td style="width:10%;padding: 1mm;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;"><?=!empty($val['time2'])?$val['time2']:'——'?></p></td>
                <td style="width:15%;padding: 1mm;font-size: 9pt;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;vertical-align: middle;"><?=$val['eat'];?></p></td>
            </tr>    
            <?php }?>    
            </tbody>
        </table>

        <?php }elseif($model->type == 2){ ?>
        <?php 
          $trip_img = [];
          if(!empty($model->trip_img)){
             $trip_img = json_decode($model->trip_img,true);
          }

        ?>
        <div class style="width: 300mm">
            <?php foreach($trip as $key=>$val){?>
            <div class="day" style="margin-top:20mm;margin-bottom: 20mm;padding-bottom: 20mm;padding-top:20mm" >
                <div class="day_title">
                    <span style="font-weight: bold;font-size: 20px;color:#0070C0;"><?=sprintf("第%s天", $key+1);?></span>
                    <span style="font-size: 12px;color: #000;font-weight: bold;margin-left: 10px;"><?=date("Y年m月d日",strtotime($dates[$key]))?> 周<?=$weekarray[date("w",strtotime($dates[$key]))]?> | <?=$val['title']?><?php if(!empty($val['time1']) || !empty($val['time2'])){?>  邮轮预计<?php if(!empty($val['time1'])){?><?=$val['time1']?> 抵港 <?php };?><?php if(!empty($val['time2'])){?><?=$val['time2']?> 离港 <?php };?>
                        <?php }?>
                    </span>
                </div>
                <div class="day_img" style="width:100%;margin-top: 10mm;margin-bottom: 10mm">
                <?php if(isset($trip_img[$key]) && !empty($trip_img[$key])){?>

                  <?php foreach($trip_img[$key] as $kimg=>$vimg){ ?> 
                      
                            <img src="<?=\Yii::$app->params['qiniu_path'].$vimg.'?imageView2/2/w/260/'?>" style="width:130mm;float: left;"?>
                     
                   <?php }?>
                 <?php }?>     
                </div>

                <div class="day_detial" style="margin-top: 10mm;margin-bottom: 10mm;">
                    <p><?=$val['desc']?></p>
                </div>

                <div class="day_other" style="margin-top: 10mm;margin-bottom: 10mm;margin-left: 20px;">
                    <p>餐食：<?=!empty($val['eat'])?$val['eat']:'无';?></p>
                    <p>交通：<?=(isset($val['traffic']) && !empty($val['traffic']))?$val['traffic']:'无';?></p>
                    <p>住宿：<?=!empty($val['room'])?$val['room']:'无';?></p>
                </div>

            </div>    
            <?php }?>  
        </div>    
        <?php }?>

    </div>

  
    <div style="margin-top: 10px;">
        <h1 style="color: red;font-size: 18px;font-weight: bold;margin-bottom:3mm;font-family: 'Microsoft YaHei';">岸上游览:</h1>
        <div style="margin:0;padding: 0;font-size: 10px;font-family: 'Microsoft YaHei';">
            <?php foreach($trip as $val){ ?>
               <?php if(isset($val['visit']) && !empty($val['visit'])){ ?>
                    <?php foreach($val['visit'] as $v){ ?>
                    <?php if(!empty($v['name'])){ ?>
                     <table style="width:300mm;margin-top: 10mm;border: 1px solid #A664A6;border-collapse:collapse;" border="2" >
                        <thead border="2">
                            <tr style="background: #A664A6;text-align: center;font-weight: bold;color: #FFFFFF;font-family: 'Microsoft YaHei';">
                                <td style="width: 45%;background: #A664A6;border: 1px solid #A664A6;font-weight: bold;color: #FFFFFF;font-family: 'Microsoft YaHei';"><p style="text-align: center;">项目</p></td>
                                <td style="width: 55%;background: #A664A6;border: 1px solid #A664A6;font-weight: bold;color: #FFFFFF;text-align: center;font-family: 'Microsoft YaHei';"><p style="text-align: center;">价格</p></td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr style="text-align:justify;">
                                <td style="padding-right: 10px;">
                                    <div style="font-size: 10pt;font-family: 'Microsoft YaHei';text-align: center;"><?=$v['name'];?></div>
                                </td>
                                <td style="border-left:2px solid #A664A6;padding-right: 10px;">
                                    <div style="font-size: 10pt;font-family: 'Microsoft YaHei';text-align: center;">¥<?=$v['price'];?></div> 
                                </td>
                            </tr> 
                            <tr style="text-align:justify;">
                                <td colspan=2 style="padding-left:15px;padding-right: 15px;border-top:1px solid #A664A6;">
                                    <div style="margin:0;padding: 0;font-size: 10px;font-family: 'Microsoft YaHei';"><?=$v['content'];?></div>
                                </td>
                            </tr>
                         </tbody>
                     </table>
                     <p>&nbsp;</p>
                     <?php }?>
                    <?php }?> 

                <?php }?>
            <?php }?>
        </div>
    </div>    
   

     <?php if(!empty($model->visa)){?>
    <div style="margin-top: 10px;">
        <h1 style="color: red;font-size: 18px;font-weight: bold;margin-bottom:3mm;font-family: 'Microsoft YaHei';">签证说明:</h1>
        <div style="margin:0;padding: 0;font-size: 10pt;font-family: 'Microsoft YaHei';"><?=$model->visa;?></div>
    </div>    
    <?php }?>
    <?php if(!empty($model->signup)){?>
    <div style="margin-top: 10px;">
        <h1 style="color: red;font-size: 18px;font-weight: bold;margin-bottom:3mm;font-family: 'Microsoft YaHei';">报名须知:</h1>
        <div style="margin:0;padding: 0;font-size: 10pt;font-family: 'Microsoft YaHei';"><?=$model->signup;?></div>
    </div>    
    <?php }?>
    <?php if(!empty($model->expense)){?>
    <div style="margin-top: 10px;">
        <h1 style="color: red;font-size: 18px;font-family: 'Microsoft YaHei';font-weight: bold;margin-bottom:3mm;">自费项目:</h1>
        <div style="margin:0;padding: 0;font-size: 10pt;font-family: 'Microsoft YaHei';"><?=$model->expense;?></div>
    </div>    
     <?php }?>

</div>

</body>


<script type="text/javascript" src="/js/html-docx-js/html-docx.js"></script>
<script type="text/javascript" src="/js/html-docx-js/vendor/FileSaver.js"></script>
<script type="text/javascript" src="http://www.xdocin.com/xdoc.js"></script>
<script type="text/javascript">
//var x = document.getElementById("htmlText").value;
//var content = '<html>'+document.getElementById("wrapper").innerHTML+'</html>';
//console.log(x);
//console.log(content);
//XDoc.run(content, "docx", {"标题":"你好"}, "_blank");
</script>
<script type="text/javascript">
    function docxs(argument) {
        var filename = '<?=$model->name?>'+'.docx';
        var content = document.getElementById("wrapper").innerHTML;
        var converted = htmlDocx.asBlob(content);
        saveAs(converted,filename);
    }
</script>
</html>